﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using spbtzb;


public partial class Back_ChangePassword : System.Web.UI.Page
{
    private Boolean session_Logined
    {
        set
        {
            Session["Logined"] = value;
        }
        get
        {
            return Session["Logined"] == null ? false : Convert.ToBoolean(Session["Logined"]);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    { 
        this.Page.Title = "帐户管理界面";
        if (!Page.IsPostBack)
        {
            if (session_Logined == false)
            {
                Response.Redirect("Login.aspx?ErrorMessage=" + "您未登录，请在此登录");
            }           
            String strUserName = ConfigurationManager.AppSettings["UserName"];
            this.tb_UserName.Text = strUserName;
            this.tb_NewName.Text = strUserName;
        }
    }
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        String strPwdOld = ConfigurationManager.AppSettings["UserPwd"];
        if (!spbtzb.AuthenCtr.verifyMd5Hash(this.tb_UserPwd.Text, strPwdOld))
        {
            div_Show.InnerHtml = "原密码错误";
            return;
        }
        try
        {
            String[] strKeys = { "UserName", "UserPwd" };
            String[] strValues = { tb_NewName.Text.Trim(), AuthenCtr.getMd5Hash(tb_NewPwd.Text.Trim()) };
            AuthenCtr.ModifyEx(strKeys, strValues);
            RegisterClientScriptBlock("tip", "<script>alert('恭喜，用户帐号密码修改成功');</script>");
        }
        catch
        {
            RegisterClientScriptBlock("tip", "<script>alert('操作失败，请重新操作或联系管理员');</script>");
        }
    }
}
